package com.ymx.darling.wrapper.fragment;

import com.ymx.darling.bean.sql.SqlStatement;

import java.util.*;

/**
 * 构建From
 * @author 爱Java的小于
 */
public class FromSegment implements SqlSegment {
    private final LinkedList<String> tables = new LinkedList<>();

    @Override
    public SqlStatement getSqlStatement() {
        StringJoiner columnJoiner = new StringJoiner(", ");
        tables.forEach(columnJoiner::add);
        return new SqlStatement(columnJoiner.toString(), new ArrayList<>());
    }

    public void from(String... tableNames){
        tables.addAll(Arrays.asList(tableNames));
    }

    public List<String> getTables() {
        return this.tables;
    }
}
